package com.xnx.bincker.leader.exception.permission;

import com.xnx.bincker.leader.exception.SystemException;
import org.springframework.security.access.AccessDeniedException;

/**
 * 没有权限异常
 */
public class PermissionDeniedException extends AccessDeniedException implements SystemException {
    private int code;
    private String tip;
    public PermissionDeniedException() {
        this("用户无操作权限");
    }

    public PermissionDeniedException(String message) {
        this(0, message, "您无此操作权限");
    }

    PermissionDeniedException(int code, String message, String tip){
        super(message);
        assert code < 1000;
        this.code = code;
        this.tip = tip;
    }

    @Override
    public int getCode() {
        return 2000 + code;
    }

    @Override
    public String getTip() {
        return tip;
    }
}
